package com.pagepub.core.ftp;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

import com.pagepub.comm.util.FormatDateTime;
import com.pagepub.core.utils.Config;
import com.pagepub.core.utils.StringUtil;
import com.pagepub.expo.entity.CorpPublication;

public class UploadImage {
	// strType电子书类型或其他 result网站的根目录 strTop是否是封面 strDestFloder删除电子书的路径
	// exitfileName文件名称
	public static final String FILE_SEPARATOR = System.getProperties()
			.getProperty("file.separator");

	public boolean DelFloderImage(String strType, String result, String strTop,
			String strDestFloder, String exitfileName) {
		boolean resultdstr = false;
		String filePath = "";
		String strIpages = "";
		String strThumb = "";
		String delExitFileName = "";
		String fileName_top_small = "thumb.jpg";
		String saveTopThumbFileName = "";
		try {

			if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {
				filePath = result + strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				strIpages = "ipages" + FILE_SEPARATOR;
				strThumb = "thumb" + FILE_SEPARATOR;
				// 删除大图文件
				delExitFileName = filePath + strIpages + exitfileName;// 删除旧文件

				java.io.File exitdelfile = new java.io.File(delExitFileName);
				exitdelfile.delete();

				// 删除小图文件
				delExitFileName = filePath + strThumb + "small_" + exitfileName;// 删除旧文件

				java.io.File exitdelfileThumb = new java.io.File(
						delExitFileName);
				exitdelfileThumb.delete();
				if ("1".equalsIgnoreCase(strTop)) {
					saveTopThumbFileName = filePath + fileName_top_small;// 删除旧文件

					java.io.File exitdelfileTop = new java.io.File(
							saveTopThumbFileName);
					exitdelfileTop.delete();
				}
			} else {

				filePath = result +Config.ImageServerURL_CORP + strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				// 删除文件
				delExitFileName = filePath;// 删除旧文件

				java.io.File exitdelnopubfile = new java.io.File(
						delExitFileName);
				exitdelnopubfile.delete();
			}
			resultdstr = true;

		} catch (Exception e) {
			System.err.print(e);
		}
		return resultdstr;
	}

	public boolean DelFloderFile(String strType, String result,
			String strDestFloder, String exitfileName) {
		boolean resultdstr = false;
		String filePath = "";
		String delExitFileName = "";

		try {

			if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {
				filePath = result +  Config.ImageServerURL_CORPPUBIMG
				+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书

				// 删除文件
				delExitFileName = filePath + exitfileName;// 删除旧文件

				java.io.File exitdelfile = new java.io.File(delExitFileName);
				exitdelfile.delete();

			} else {

				filePath = result + Config.ImageServerURL_CORP+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径新闻类
				// 删除文件
				delExitFileName = filePath;// 删除旧文件

				java.io.File exitdelnopubfile = new java.io.File(
						delExitFileName);
				exitdelnopubfile.delete();
			}
			resultdstr = true;

		} catch (Exception e) {
			System.err.print(e);
		}
		return resultdstr;
	}

	public String UploadImages(File file, String fileName, String username,
			String result, String strType, String strDestFloder, String strTop,
			String strBottom, String strBackGroup, int width, int height,
			int pubtype) {
		String resultdstr = "false";
		String saveFileName = "";
		String saveThumbFileName = "";
		String saveTopThumbFileName = "";
		String filePath = "";
		String fileExt = "";
		String strIpages = "";
		String strThumb = "";
		String fileName_small = "";
		String setTop = "1";
		String setBottom = "1";
		String fileName_top_small = "thumb.jpg";

		String[] suffixs = fileName.split("[.]");
		String realFileName = username
				+ FormatDateTime.getToday("yyyyMMddHHmmss") + ".";
		// 创建文件名

		realFileName = realFileName
				+ (suffixs != null && suffixs.length > 1 ? suffixs[suffixs.length - 1]
						: "");
		// 测试该文件是不是合法
		resultdstr = realFileName;
		if (!StringUtil.isValidFile(fileName)) {
			resultdstr = "false";
			return resultdstr;
		}

		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		InputStream is = null;
		OutputStream fos = null;
		try {
			is = (InputStream) new FileInputStream(file);// 把文件读入
			int fileSize = is.available();// 取得文件尺寸
			// 文件物理上传通过getInputStream()方法取得文件流// 文件最大限额

			int fileMaxSize = 10 * 1024 * 1024;
			if (fileSize > fileMaxSize) {
				// 文件大小不能超过fileMaxSize，如果超过，报"上传文件尺寸超过10M"错误；

				resultdstr = "false";
				return resultdstr;
			}
			bis = new BufferedInputStream(is);
			// FILE_SEPARATOR表示分隔符，按照操作系统不同有所不同，UNIX上是´/´，Windows上是´\´。
			if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {
				filePath = result + FILE_SEPARATOR+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				strIpages = "ipages" + FILE_SEPARATOR;
				strThumb = "thumb" + FILE_SEPARATOR;
				fileExt = fileName.substring(fileName.lastIndexOf(".") + 1,
						fileName.length());
				fileName_small = "small_" + realFileName;// 用于缩略小图显示
				// 保存上传文件
				boolean existsstrIpages = (new File(filePath + strIpages))
						.exists();
				if (!existsstrIpages) {
					(new File(filePath + strIpages)).mkdirs();
				}

				saveFileName = filePath + strIpages + realFileName;
				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}

				boolean existsstrThumb = (new File(filePath + strThumb))
						.exists();
				if (!existsstrThumb) {
					(new File(filePath + strThumb)).mkdirs();
				}

				saveThumbFileName = filePath + strThumb + fileName_small;
				saveTopThumbFileName = filePath + fileName_top_small;

			} else {
				filePath = result + Config.ImageServerURL_CORP + strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书

				fileExt = fileName.substring(fileName.lastIndexOf(".") + 1,
						fileName.length());
				// 保存上传文件
				boolean exists = (new File(filePath)).exists();
				if (!exists) {
					(new File(filePath)).mkdirs();
				}
				saveFileName = filePath + FILE_SEPARATOR + realFileName;
				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}
			}

		} catch (IOException e) {
			// 设置文件物理上传出现问题时的出现的错误信息

			e.printStackTrace();
			resultdstr = "false";
		} finally {
			if (bos != null) {

				try {
					bos.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
			if (bis != null) {
				try {
					bis.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
		}
		if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {
			try {
				if (!"swf".equals(fileExt.toLowerCase())) {
					int widtha = 0;
					int heighta = 0;
					if (pubtype == 1) {
						// double wy = (double) width * 450 / 731;
						// widtha = (int) wy;
						widtha = width * 45 / 100;
						heighta = height * 45 / 100;
					} else {
						widtha = width * 2 * 45 / 100;
						heighta = height * 2 * 45 / 100;
					}

					if (setTop.equals(strTop)) {
						new ImgDeal().reduceImgJbg(saveFileName,
								saveTopThumbFileName, 120, 170);
						new ImgDeal().reduceImgJbg(saveFileName,
								saveThumbFileName, width * 45 / 100,
								height * 45 / 100);
					} else {
						// 如果是封底

						if (setBottom.equals(strBottom)) {
							new ImgDeal().reduceImgJbg(saveFileName,
									saveThumbFileName, width * 45 / 100,
									height * 45 / 100);
						} else {
							new ImgDeal().reduceImgJbg(saveFileName,
									saveThumbFileName, widtha, heighta);
						}

					}

				}
				Thread.sleep(1500);
			} catch (Exception e1) {
				// TODO 自动生成 catch 块

				e1.printStackTrace();
				System.out.println(e1.getMessage());
			}
		}

		return resultdstr;
	}

	public String ModUploadImage(File file, String fileName, String username, String result,
			String strType, String strDestFloder, String strTop,
			String strBottom, String strbackgroup, String strOldDestFloder,
			String exitfileName, int width, int height, int pubtype) {
		String resultdstr = "false";
		String saveFileName = "";
		String delExitFileName = "";
		String saveThumbFileName = "";
		String saveTopThumbFileName = "";
		String filePathold = "";
		String filePath = "";
		String fileExt = "";
		String strIpages = "";
		String strThumb = "";
		String fileName_small = "";
		String setTop = "1";
		String setBottom = "1";
		String fileName_top_small = Config.FileNameTopThumb;
		String[] suffixs = fileName.split("[.]");
		String realFileName = username
				+ FormatDateTime.getToday("yyyyMMddHHmmss") + ".";
		// 创建文件名

		realFileName = realFileName
				+ (suffixs != null && suffixs.length > 1 ? suffixs[suffixs.length - 1]
						: "");
		// 测试该文件是不是合法
		resultdstr = realFileName;
		if (!StringUtil.isValidFile(fileName)) {
			resultdstr = "false";
			return resultdstr;
		}
		
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		InputStream is = null;
		OutputStream fos = null;
		try {
			is = (InputStream) new FileInputStream(file);// 把文件读入
			int fileSize = is.available();// 取得文件尺寸
			// 文件物理上传通过getInputStream()方法取得文件流// 文件最大限额

			int fileMaxSize = 10 * 1024 * 1024;
			if (fileSize > fileMaxSize) {
				// 文件大小不能超过fileMaxSize，如果超过，报"上传文件尺寸超过10M"错误；

				resultdstr = "false";
				return resultdstr;
			}
			bis = new BufferedInputStream(is);
			// FILE_SEPARATOR表示分隔符，按照操作系统不同有所不同，UNIX上是´/´，Windows上是´\´。

			if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {
				filePathold = result+ Config.ImageServerURL_CORPPUBIMG + strOldDestFloder + FILE_SEPARATOR;// 旧路径取当前系统路径电子书

				filePath = result + Config.ImageServerURL_CORPPUBIMG+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				strIpages = "ipages" + FILE_SEPARATOR;
				strThumb = "thumb" + FILE_SEPARATOR;
				fileExt = fileName.substring(fileName.lastIndexOf(".") + 1,
						fileName.length());
				fileName_small = "small_"
						+ fileName.substring(0, fileName.lastIndexOf("."))
						+ "." + fileExt;// 用于缩略小图显示
				// 保存上传文件
				boolean existsstrIpages = (new File(filePath + strIpages))
						.exists();
				if (!existsstrIpages) {
					(new File(filePath + strIpages)).mkdirs();
				}

				// 删除文件
				delExitFileName = filePathold + strIpages + exitfileName;// 删除旧文件

				java.io.File exitdelfile = new java.io.File(delExitFileName);
				exitdelfile.delete();

				saveFileName = filePath + strIpages + realFileName;
				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}

				boolean existsstrThumb = (new File(filePath + strThumb))
						.exists();
				if (!existsstrThumb) {
					(new File(filePath + strThumb)).mkdirs();
				}

			} else {
				filePathold = result  + Config.ImageServerURL_CORP+ strOldDestFloder;// 旧路径取当前系统路径电子书

				filePath = result  + Config.ImageServerURL_CORP+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				fileExt = fileName.substring(fileName.lastIndexOf(".") + 1,
						fileName.length());
				// 保存上传文件
				boolean exists = (new File(filePath)).exists();
				if (!exists) {
					(new File(filePath)).mkdirs();
				}
				// 删除文件
				delExitFileName = filePathold;// 删除旧文件

				java.io.File exitdelnopubfile = new java.io.File(
						delExitFileName);
				exitdelnopubfile.delete();
				saveFileName = filePath + FILE_SEPARATOR + realFileName;

				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}
			}

		} catch (IOException e) {
			// 设置文件物理上传出现问题时的出现的错误信息

			e.printStackTrace();
			resultdstr = "false";
		} finally {
			if (bos != null) {

				try {
					bos.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
			if (bis != null) {
				try {
					bis.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
		}
		if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {

			try {

				if (!"swf".equals(fileExt.toLowerCase())) {
					// 删除文件
					delExitFileName = filePathold + strThumb + "small_"
							+ exitfileName;// 删除旧文件

					java.io.File exitdelfileThumb = new java.io.File(
							delExitFileName);
					exitdelfileThumb.delete();
					saveThumbFileName = filePath + strThumb + "small_"
							+ realFileName;
					saveTopThumbFileName = filePath + fileName_top_small;
					int widtha = 0;
					if (pubtype == 1) {
						// double wy = (double) width * 450 / 731;
						// widtha = (int) wy;
						widtha = width * 45 / 100;
					} else {
						// double wy = (double) width * 2 * 450 / 731;
						// widtha = (int) wy;
						widtha = width * 2 * 45 / 100;
					}
					int heighta = 0;

					if (pubtype == 1) {
						// double hx = (double) height * 450 / 731;
						// heighta = (int) hx;
						heighta = height * 45 / 100;
					} else {
						// double hx = (double) height * 2 * 450 / 731;
						// heighta = (int) hx;
						heighta = height * 2 * 45 / 100;
					}

					if (setTop.equals(strTop)) {
						saveTopThumbFileName = filePathold + fileName_top_small;// 删除旧文件

						java.io.File exitdelfileTop = new java.io.File(
								saveTopThumbFileName);
						exitdelfileTop.delete();
						// double twy = (double) 120 * 1000 / 731;
						// int twidth = (int) twy;
						// double thx = (double) 170 * 1000 / 731;
						// int theight = (int) thx;
						new ImgDeal().reduceImgJbg(saveFileName,
								saveThumbFileName, width * 45 / 100,
								height * 45 / 100);
						new ImgDeal().reduceImgJbg(saveFileName,
								saveTopThumbFileName, 120, 170);
					} else {
						// 如果是封底

						if (setBottom.equals(strBottom)) {
							new ImgDeal().reduceImgJbg(saveFileName,
									saveThumbFileName, width * 45 / 100,
									height * 45 / 100);
						} else {
							new ImgDeal().reduceImgJbg(saveFileName,
									saveThumbFileName, widtha, heighta);
						}

					}

				}
			} catch (Exception e1) {
				// TODO 自动生成 catch 块

				e1.printStackTrace();
				System.out.println(e1.getMessage());
			}
		}
		return resultdstr;
	}

	public String UploadMeadiaFile(File file, String fileName, String username,
			String result, String strType, String strDestFloder) {
		String resultdstr = "false";
		String saveFileName = "";
		String filePath = "";
		String[] suffixs = fileName.split("[.]");
		String realFileName = username
				+ FormatDateTime.getToday("yyyyMMddHHmmss") + ".";
		// 创建文件名

		realFileName = realFileName
				+ (suffixs != null && suffixs.length > 1 ? suffixs[suffixs.length - 1]
						: "");
		// 测试该文件是不是合法
		resultdstr = realFileName;
		if (!StringUtil.isValidFile(fileName)) {
			resultdstr = "false";
			return resultdstr;
		}
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		InputStream is = null;
		OutputStream fos = null;
		try {
			
			is = (InputStream) new FileInputStream(file);// 把文件读入
			int fileSize = is.available();// 取得文件尺寸
			// 文件物理上传通过getInputStream()方法取得文件流// 文件最大限额

			int fileMaxSize = 50 * 1024 * 1024;
			if (fileSize > fileMaxSize) {
				// 文件大小不能超过fileMaxSize，如果超过，报"上传文件尺寸超过10M"错误；

				resultdstr = "false";
				return resultdstr;
			}

			bis = new BufferedInputStream(is);
			// FILE_SEPARATOR表示分隔符，按照操作系统不同有所不同，UNIX上是´/´，Windows上是´\´。

			if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {
				filePath = result + Config.ImageServerURL_CORPPUBIMG+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				// 保存上传文件
				boolean exists = (new File(filePath)).exists();
				if (!exists) {
					(new File(filePath)).mkdirs();
				}

				saveFileName = filePath + realFileName;
				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}

			} else {
				filePath = result  + Config.ImageServerURL_CORP + strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				// 保存上传文件
				boolean exists = (new File(filePath)).exists();
				if (!exists) {
					(new File(filePath)).mkdirs();
				}
				saveFileName = filePath + FILE_SEPARATOR + realFileName;
				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}
			}

		} catch (IOException e) {
			// 设置文件物理上传出现问题时的出现的错误信息

			e.printStackTrace();
			resultdstr = "false";
		} finally {
			if (bos != null) {

				try {
					bos.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
			if (bis != null) {
				try {
					bis.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
		}
		return resultdstr;
	}

	public String ModUploadMeadiaFile(File file, String fileName,String username,
			String result, String strType, String strDestFloder,
			String strOldDestFloder, String exitfileName) {
		String resultdstr = "false";
		String saveFileName = "";
		String delExitFileName = "";
		String filePath = "";
		String filePathold = "";
		String[] suffixs = fileName.split("[.]");
		String realFileName = username
				+ FormatDateTime.getToday("yyyyMMddHHmmss") + ".";
		// 创建文件名

		realFileName = realFileName
				+ (suffixs != null && suffixs.length > 1 ? suffixs[suffixs.length - 1]
						: "");
		// 测试该文件是不是合法
		resultdstr = realFileName;
		if (!StringUtil.isValidFile(fileName)) {
			resultdstr = "false";
			return resultdstr;
		}
		
		BufferedInputStream bis = null;
		BufferedOutputStream bos = null;
		InputStream is = null;
		OutputStream fos = null;
		try {
			is = (InputStream) new FileInputStream(file);// 把文件读入
			int fileSize = is.available();// 取得文件尺寸
			// 文件物理上传通过getInputStream()方法取得文件流// 文件最大限额

			int fileMaxSize = 50 * 1024 * 1024;
			if (fileSize > fileMaxSize) {
				// 文件大小不能超过fileMaxSize，如果超过，报"上传文件尺寸超过10M"错误；

				resultdstr = "false";
				return resultdstr;
			}

			bis = new BufferedInputStream(is);
			// FILE_SEPARATOR表示分隔符，按照操作系统不同有所不同，UNIX上是´/´，Windows上是´\´。

			if ((Config.UpIMGTypePub).equalsIgnoreCase(strType)) {
				filePathold = result  + Config.ImageServerURL_CORPPUBIMG+ strOldDestFloder + FILE_SEPARATOR;// 旧路径取当前系统路径电子书

				filePath = result  + Config.ImageServerURL_CORPPUBIMG+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				// 保存上传文件
				boolean exists = (new File(filePath)).exists();
				if (!exists) {
					(new File(filePath)).mkdirs();
				}
				delExitFileName = filePathold + exitfileName;// 删除旧文件

				java.io.File exitdelfile = new java.io.File(delExitFileName);
				exitdelfile.delete();
				saveFileName = filePath + realFileName;
				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}

			} else {
				filePathold = result + Config.ImageServerURL_CORP+ strOldDestFloder + FILE_SEPARATOR;// 旧路径取当前系统路径电子书

				filePath = result + Config.ImageServerURL_CORP+ strDestFloder + FILE_SEPARATOR;// 取当前系统路径电子书
				// 保存上传文件
				boolean exists = (new File(filePath)).exists();
				if (!exists) {
					(new File(filePath)).mkdirs();
				}
				delExitFileName = filePathold;// 删除旧文件

				java.io.File exitdelfile = new java.io.File(delExitFileName);
				exitdelfile.delete();

				saveFileName = filePath + FILE_SEPARATOR + realFileName;
				fos = new FileOutputStream(saveFileName);// 建立一个上传文件的输出流

				bos = new BufferedOutputStream(fos);
				int bytesRead = 0;
				byte[] buffer = new byte[5 * 1024];
				while ((bytesRead = bis.read(buffer)) != -1) {
					bos.write(buffer, 0, bytesRead);// 将文件写入服务器
				}
			}

		} catch (IOException e) {
			// 设置文件物理上传出现问题时的出现的错误信息

			e.printStackTrace();
			resultdstr = "false";
		} finally {
			if (bos != null) {

				try {
					bos.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
			if (bis != null) {
				try {
					bis.close();
				} catch (IOException e) {
					System.err.print(e);
				}
			}
		}
		return resultdstr;
	}

	public String UploadBatchImage(
			com.jspsmart.upload.smartUpload.SmartFile myeFile,
			CorpPublication publication, String result, String strDestFloder) {
		String resultdstr = "false";
		String fileName = myeFile.getFileName();// 取得文件名

		String[] suffixs = myeFile.getFileName().split("[.]");
		String realFileName = publication.getCorpId()
				+ FormatDateTime.getToday("yyyyMMddHHmmss") + ".";
		// 创建文件名

		realFileName = realFileName
				+ (suffixs != null && suffixs.length > 1 ? suffixs[suffixs.length - 1]
						: "");
		// 测试该文件是不是合法
		resultdstr = realFileName;
		if (!StringUtil.isValidFile(fileName)) {
			resultdstr = "false";
			return resultdstr;
		}
		try {
			myeFile.saveAs(result + realFileName);

		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
		return resultdstr;
	}

}